using System.Linq;
using UnityEngine;

namespace MaterialUI
{
	public static class MaterialUIIconHelper
	{
		private static Font m_Font;

		private static VectorImageSet m_IconSet;

		static MaterialUIIconHelper()
		{
			if (m_Font == null)
			{
				m_Font = VectorImageManager.GetIconFont("MaterialUI Icons");
			}
			if (m_IconSet == null)
			{
				m_IconSet = VectorImageManager.GetIconSet("MaterialUI Icons");
			}
		}

		public static ImageData GetIcon(string name)
		{
			Glyph glyph = (from x in m_IconSet.iconGlyphList
				where x.name.ToLower().Equals(name.ToLower())
				select x).FirstOrDefault();
			if (glyph == null)
			{
				UnityEngine.Debug.LogError("Could not find an icon with the name: " + name + " inside the MaterialDesign icon font");
				return null;
			}
			return new ImageData(new VectorImageData(glyph, m_Font));
		}

		public static ImageData GetRandomIcon()
		{
			return new ImageData(new VectorImageData(m_IconSet.iconGlyphList[Random.Range(0, m_IconSet.iconGlyphList.Count)], m_Font));
		}
	}
}
